package com.itheima.stream流.多种获取方法.集合的元素收集到Map;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Map;
import java.util.stream.Collector;
import java.util.stream.Collectors;

public class Test5 {
    public static void main(String[] args) {
        ArrayList<String>list=new ArrayList<>();
        list.add("zhangsan,23");
        list.add("lisi,24");
        list.add("wangwu,25");

      Map<String,String>map=list.stream().filter(s->{String[]split=s.split(",");
                    int age = Integer.parseInt(split[1]);
                    return age>=24;}).collect(Collectors.toMap(s->s.split(",")[0],
                        s->s.split(",")[1]));


        System.out.println(map);
    }
}
